Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix #155 #161

Merged
merged 1 commit into from
Oct 6, 2018
Merged

fix #155 #161

merged 1 commit into from
Oct 6, 2018

Conversation

silkentrance
Copy link
Collaborator

@silkentrance silkentrance commented Dec 1, 2017

With this in place, the user will be handed out an async remove callback, as requested in #155. Internally, we will be using the sync remove callback so that on process exit, everything is done synchronously.

This also fixes existing async tests, at last.

  • The problem with the existing async test code was, erm, that assertions had been made outside of a try catch statement, leading to tests that seemed to work just fine, however, done() was never called in case of error.

  • 😕 still wondering why the tests seemed to be working, tough. Must be because the code base is working just fine 👍

  • In order to be able to clean up without having to do everything by hand, requiring deeper knowledge of the actual test cases, rimraf was added as a dev dependency.

  • @raszi I am also considering to use it for async recursive dir/file removal, and also for sync dir/file removal. that way we could eliminate a lot of code from tmp. What do you think? rimraf seems to be stable and also provides a work around for weird win32 platform related issues.

@silkentrance
Copy link
Collaborator Author

silkentrance commented Dec 7, 2017

@raszi are you ok with adding the rimraf dependency and eliminating our own code? as otherwise, we would have to reimplement rimraf for async operation.

If so, I would then proceed and merge this to master ASAP, after the cleanup of course.

@silkentrance silkentrance mentioned this pull request Dec 7, 2017
@silkentrance silkentrance force-pushed the gh-155 branch 2 times, most recently from 8f665db to 7c51078 Compare December 27, 2017 02:39
@raszi
Copy link
Owner

raszi commented Jan 29, 2018

Well, I would have no problems introducing a small dependency for the job and removing our code. My concerns with rimraf are the followings:

  • it has an another dependency on glob
  • the builds are failing on the master branch for the older Node versions

@silkentrance
Copy link
Collaborator Author

@raszi Sorry for not coming back to you and working on this for quite a while now. I will see whether there is a different approach to that.

@silkentrance
Copy link
Collaborator Author

@raszi the glob package is also used by npm itself, and, according to npm stats, it has a whopping 15mil (not US billion) downloads. In fact, it is a well proven dependency.

As to the failing tests, since we eliminated node < 0.10.0 the tests are no longer failing.

@silkentrance silkentrance force-pushed the gh-155 branch 2 times, most recently from 15305b8 to 7d25c8c Compare April 30, 2018 22:05
@silkentrance
Copy link
Collaborator Author

silkentrance commented Apr 30, 2018

@raszi I fixed the order by which the tests cleanup their remnant temporary files. Sometimes, especially with node 0.10.x this would fail and done() would not be called.

@silkentrance
Copy link
Collaborator Author

rebased to master

@kaiserfro
Copy link

Can this PR be merged?

@silkentrance
Copy link
Collaborator Author

@kaiserfro From my part yes, but @raszi had some reservations towards the introduction of the dependency towards the glob package.
As for merging, I can do that, but publishing a new version on npm I cannot do.

@silkentrance
Copy link
Collaborator Author

@kaiserfro since this integrates the latest changes from master, you could use a github reference for your dependency, unless you do not want to do that.
alternatively you could publish this to an instance of verdaccio that you run on your site or even nexus acting as an npm registry.

fix order by which tests rimraf their leftovers
@silkentrance
Copy link
Collaborator Author

@raszi since I have not heard back from you for a long time and since people actually need this functionality, I will continue with merging this into master as soon as all tests have succeeded.
At least the appveyor builds are not working again.

@silkentrance silkentrance merged commit fcbf27b into master Oct 6, 2018
@silkentrance silkentrance deleted the gh-155 branch October 6, 2018 15:25
throw e;
}
// reraise any unanticipated error
if (!isENOENT(e)) throw e;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause a linter error because of no-unsafe-finally.

next();
}

if (0 <= fdPath[0])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too dense and error prone. Please put parentheses around the branches.

if (!opts.keep) {
_removeObjects.unshift(removeCallback);
}
const removeFunction = opts.unsafeCleanup ? _rimrafRemoveDirWrapper : fs.rmdir.bind(fs);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically calling rimraf. Why do we need a wrapper for this?

* Simple wrapper for rimraf.sync.
*
* @param {string} dirPath
* @private
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next parameter is not documented.

@@ -3,6 +3,7 @@
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "7"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, how did I miss this?


if (0 <= fdPath[0])
fs.close(fdPath[0], function (err) {
fs.unlink(fdPath[1], _handler);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should extract this to a local function because it is also used in the else branch.

const _removeFile = function () { fs.unlink(fdPath[1], _handler); }

@raszi
Copy link
Owner

raszi commented Oct 8, 2018

Sorry for the delay, this is a super busy period of my life.

@silkentrance
Copy link
Collaborator Author

@raszi I am currently also rather busy. Thanks for the review. I will try to fix these issues ASAP.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants